package com.fufu.util;

import java.util.ArrayList;
import java.util.List;

/**
 * 手动分页
 */
public class PageUtils {
    public static List getPage(List dataList, int pageNumber, int pageSize) {
        int totalItems = dataList.size();
        int startIndex = (pageNumber - 1) * pageSize;
        int endIndex = Math.min(pageNumber * pageSize, totalItems);
        if (startIndex >= totalItems || pageNumber < 1) {
            return new ArrayList<>();
        }
        return new ArrayList<>(dataList.subList(startIndex, endIndex));
    }


}
